# var mongoose = require('mongoose');
# var databaseConfig = require('../config').database;
Mongoose = require 'mongoose'
Config = require '../config'
MongoConfig = Config.mongo
Logger = require('log4js').getLogger()

mongooseConnectStr = "mongodb://#{MongoConfig.user}:#{MongoConfig.pwd}@#{MongoConfig.host}:#{MongoConfig.port}/#{MongoConfig.db}"

Logger.info "mongooseConnectStr:#{mongooseConnectStr}"

mongooseConOptions =
  server :
    poolSize : MongoConfig.poolSize
conn = Mongoose.createConnection mongooseConnectStr, mongooseConOptions, (err) ->
  if err
    Logger.error "mongoose error:#{err}"




Article = conn.model 'Article', require './schema/article'
Reflection = conn.model 'Reflection', require './schema/reflection'
RecommendArticle = conn.model 'RecommendArticle', require './schema/recommend_article'
User = conn.model 'User', require './schema/user'
Message = conn.model 'Message', require './schema/message'


module.exports = 
  Article : Article
  Reflection : Reflection
  RecommendArticle : RecommendArticle
  User : User